<template>
	<view>
		<u-navbar :is-back="true" title="线上问诊" :background="background"></u-navbar>
		<view class="wrap bg">
			<view class="u-tabs-box">
				<u-tabs-swiper activeColor="#2979ff" ref="tabs" :list="list" :current="current" @change="change"
					:is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view>
			<!-- 线上问诊 -->
			<swiper class="swiper-box" :current="swiperCurrent" @transition="transition"
				@animationfinish="animationfinish">
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;">
						<view class="" v-if="orderslist0==[]">
							此页无订单
						</view>
						<view class="u-flex u-m-l-26 u-m-r-26 u-p-t-26 u-p-b-26 li_line"
							v-for="(item,index) in orderslist0" :key="index">
							<view class="u-flex-1" style="width: 100rpx;height: 100rpx;">
								<image :src=item.userinfo.avatar style="width: 75rpx;height: 75rpx;border-radius: 50%;">
								</image>
							</view>
							<view class="u-flex-5 top">
								<p class="u-font-12">{{item.userinfo.nickname}}</p>
								<text style="color: #9e9e9e;font-size: 12rpx;">{{item.part}}</text>
							</view>
							<view class="u-flex-1">
								<u-button size="mini" type="primary" shape="circle"
									@click="openinfo('/pages/order/lineOn/lineItem/lineItem?id='+item.id+'&name='+item.userinfo.nickname)">接受</u-button>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;">
						<view class="" v-if="orderslist1==[]">
							此页无订单
						</view>
						<view class="u-flex u-m-l-26 u-m-r-26 u-p-t-26 u-p-b-26 li_line"
							v-for="(item,index) in orderslist1" :key="index">
							<view class="u-flex-1" style="width: 100rpx;height: 100rpx;">
								<image :src=item.userinfo.avatar style="width: 75rpx;height: 75rpx;border-radius: 50%;">
								</image>
							</view>
							<view class="u-flex-5 top">
								<p class="u-font-12">{{item.userinfo.nickname}}</p>
								<text style="color: #9e9e9e;font-size: 12rpx;">{{item.part}}</text>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;">
						<view class="" v-if="orderslist2==[]">
							此页无订单
						</view>
						<view class="u-flex u-m-l-26 u-m-r-26 u-p-t-26 u-p-b-26 li_line"
							v-for="(item,index) in orderslist2" :key="index">
							<view class="u-flex-1" style="width: 100rpx;height: 100rpx;">
								<image :src=item.userinfo.avatar style="width: 75rpx;height: 75rpx;border-radius: 50%;">
								</image>
							</view>
							<view class="u-flex-5 top">
								<p class="u-font-12">{{item.userinfo.nickname}}</p>
								<text style="color: #9e9e9e;font-size: 12rpx;">{{item.part}}</text>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;">
						<view class="" v-if="orderslist3==[]">
							此页无订单
						</view>
						<view class="u-flex u-m-l-26 u-m-r-26 u-p-t-26 u-p-b-26 li_line"
							v-for="(item,index) in orderslist3" :key="index">
							<view class="u-flex-1" style="width: 100rpx;height: 100rpx;">
								<image :src=item.userinfo.avatar style="width: 75rpx;height: 75rpx;border-radius: 50%;">
								</image>
							</view>
							<view class="u-flex-5 top">
								<p class="u-font-12">{{item.userinfo.nickname}}</p>
								<text style="color: #9e9e9e;font-size: 12rpx;">{{item.part}}</text>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#00a8ff'
				},
				list: [{
						name: '待确定'
					},
					{
						name: '待面诊'
					},
					{
						name: '进行中'
					},
					{
						name: '已完成',
					}
				],
				current: 0,
				swiperCurrent: 0,
				tabsHeight: 0,
				dx: 0,
				orderslist0: [],
				orderslist1: [],
				orderslist2: [],
				orderslist3: []
			};
		},
		onLoad() {
			this.getOrderslist();
		},
		computed: {},
		methods: {
			// 获取订单列表
			getOrderslist() {
				this.$apiVipCentre.orderslist({
					page: '',
					limit: '',
					show_status: '0'
				}).then((res) => {
					console.log('request success', res);
					uni.showToast({
						title: res.data.code,
						icon: 'success',
						mask: true
					});
					console.log(res.data.data.items)
					this.orderslist0 = res.data.data.items;
					// this.groupList = res.data.data;
					let time = this.$u.timeFormat(res.data.time, 'yyyy-mm-dd hh:MM');
					console.log(time);
				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			// 页面跳转
			openinfo(url) {
				uni.navigateTo({
					url: url,
				});
			},
			// tab栏切换
			change(index) {
				console.log(index)
				this.swiperCurrent = index;
				this.$apiVipCentre.orderslist({
					page: '',
					limit: '',
					show_status: index
				}).then((res) => {
					console.log('request success', res);
					uni.showToast({
						title: res.data.code,
						icon: 'success',
						mask: true
					});
					if (index == 0) {
						this.orderslist0 = res.data.data.items;
					} else if (index == 1) {
						this.orderslist1 = res.data.data.items;
					} else if (index == 2) {
						this.orderslist2 = res.data.data.items;
					} else if (index == 3) {
						this.orderslist3 = res.data.data.items;
					}

					// this.groupList = res.data.data;
					let time = this.$u.timeFormat(res.data.time, 'yyyy-mm-dd hh:MM');
					console.log(time);

				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			transition({
				detail: {
					dx
				}
			}) {
				this.$refs.tabs.setDx(dx);
			},
			animationfinish({
				detail: {
					current
				}
			}) {
				this.$refs.tabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			}
		}
	};
</script>



<style lang="scss" scoped>
	.top{
		position: relative;
		top: -10rpx;
	}
	.li_line {
		border-bottom: 1px #eaeaea solid;
	}

	.bg {
		background-color: #f3f4f6;
	}

	.cnbg {
		background-color: #FFFFFF;
	}

	.order {
		width: 710rpx;
		background-color: #ffffff;
		margin: 20rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		font-size: 28rpx;

		.top {
			display: flex;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;

				.store {
					margin: 0 10rpx;
					font-size: 32rpx;
					font-weight: bold;
				}
			}

			.right {
				color: $u-type-warning-dark;
			}
		}

		.item {
			display: flex;
			margin: 20rpx 0 0;

			.left {
				margin-right: 20rpx;

				image {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
				}
			}

			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}

				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}

				.delivery-time {
					color: #e5d001;
					font-size: 24rpx;
				}
			}

			.right {
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;

				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}

				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}

		.total {
			margin-top: 20rpx;
			text-align: right;
			font-size: 24rpx;

			.total-price {
				font-size: 32rpx;
			}
		}

		.bottom {
			display: flex;
			margin-top: 40rpx;
			padding: 0 10rpx;
			justify-content: space-between;
			align-items: center;

			.btn {
				line-height: 52rpx;
				width: 160rpx;
				border-radius: 26rpx;
				border: 2rpx solid $u-border-color;
				font-size: 26rpx;
				text-align: center;
				color: $u-type-info-dark;
			}

			.evaluate {
				color: $u-type-warning-dark;
				border-color: $u-type-warning-dark;
			}
		}
	}


	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}

	// .swiper-box {
	// 	flex: 1;
	// }

	.swiper-item {
		height: 100%;
	}
</style>
